package com.amt.olcacon.mapper;

import com.amt.olcacon.bo.GetProviderInfo;
import com.amt.olcacon.bo.productDefultProcess;
import com.amt.olcacon.entity.ProcessEntity;
import com.amt.olcacon.entity.ProductProcessEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProductProcessMapper extends BaseMapper<ProductProcessEntity> {



    @Select("select id from global_regions where name = #{name}")
    Long getGlobalRegions(String name);

    @Select("select id from tbl_locations where name = #{name}")
    Long gettblLocations(String name);

    productDefultProcess getProductDefultProcess(Long taskId);

    @Select("SELECT\n" +
            "\ttp.id as id,\n" +
            "\ttrim(tp.NAME) as name,\n" +
            "\ttrim(tl.`CODE`) as locationCode\n" +
            "FROM\n" +
            "\ttbl_processes tp\n" +
            "\tLEFT JOIN tbl_locations tl ON tp.F_LOCATION = tl.id\n" +
            "WHERE\n" +
            "\tTRIM(tp.`NAME`) = #{name}\n" +
            "\tand TRIM(tl.`CODE`) = #{locationCode}")
    List<GetProviderInfo> getProviderInfo(@Param("name") String name, @Param("locationCode") String locationCode);

}
